<?php 

if ($_POST) {
	
	$pregs = array(
		'username'=>array(
			'preg'=>'/^[a-z]{4,8}$/',
			'info'=>'用户名必须是4-8位的字母'
			),
		'password'=>array(
			'preg'=>'/^[a-z0-9]{4,8}$/',
			'info'=>'密码长度必要是4-8的字母或数字'
			)

		);

	$file = array_keys($_POST);

	$data = $_POST[$file[0]];

	$c = preg_match($pregs[$file[0]]['preg'], $data);

	if($c){
		$arr = array(
			'error'=>1,
			'info'=>$data
			);
		echo json_encode($arr);


	}else{

		$arr = array(
			'error'=>0,
			'info'=>$pregs[$file[0]]['info']
			);

		echo json_encode($arr);
	}


}













 ?>